import http from "@/api";
import qs from "qs";
import { MeasureListType } from "./type";

// 使用枚举包含所有的Path
enum Api {
  // 查询度量列表
  selectMeasureList = "/tbMeasure/select",
  // 添加度量
  addMeasure = "/tbMeasure/add",
  // 删除度量
  deleteMeasure = "/tbMeasure/delete"
}

// 查询度量列表的Api
export const selectMeasureListApi = () => {
  return http.post<MeasureListType>(Api.selectMeasureList, {}, { loading: false });
};

// 添加度量的Api
export const addMeasureApi = (data: { name: string }) => {
  let dataQ = "?" + qs.stringify(data);
  return http.post(Api.addMeasure + dataQ, {}, { loading: false });
};

// 删除度量的Api
export const deleteMeasureApi = (data: { id: number }) => {
  let dataQ = "?" + qs.stringify(data);
  return http.post(Api.deleteMeasure + dataQ, {}, { loading: false });
};
